<template>
    <div class="index">
        <h1>test</h1>
        <button @click="test">test</button>
        <button @click="ajax">ajax</button>
        <div v-html="msg">

        </div>
    </div>
</template>

<script type="text/ecmascript-6">
    export default {
        name: 'NcIndex',
        data() {
            return {
                msg: {}
            }
        },
        mounted() {
            this.$nextTick(() => {

            })
        },
        methods: {
            async test() {
                try {
                    const [res, all] = await this.$$http.get('https://www.baidu.com');
                    alert(res)
                    this.msg = res;
                } catch (e) {
                    alert(JSON.stringify(e))
                }
            },
            async ajax() {
                this.$$get('/json')
                    .then(res => {
                        this.msg = res;
                        alert(JSON.stringify(res));
                    })
                    .catch(err => {
                        this.msg = err;
                        alert(JSON.stringify(err));
                    });
            }
        }
    }
</script>

<style lang="stylus" rel="stylesheet/stylus">
    .index {

    }
</style>